const requiredHeaders = {
  headers: {
    type: "object",
    properties: {
      token: { type: "string" },
    },
    required: ["token"],
  },
};

exports.WXminLoginSchema = {
  summary: "微信小程序登录",
  tags: ["Common"],
  body: {
    type: "object",
    properties: {
      appid: { type: "string", description: "appid" },
      code: { type: "string", description: "code" },
      secret: { type: "string", description: "secret" },
    },
  },
};

exports.LoginSchema = {
  summary: "账户登录",
  tags: ["Common"],
  body: {
    type: "object",
    properties: {
      account: { type: "string", description: "账户" },
      password: { type: "string", description: "密码" },
    },
  },
};

exports.PhoneLoginSchema = {
  summary: "手机登录",
  tags: ["Common"],
  body: {
    type: "object",
    properties: {
      phone: { type: "string", description: "手机号" },
      code: { type: "string", description: "短信验证码" },
    },
  },
};

exports.RegistrationSchema = {
  summary: "账户注册",
  tags: ["Common"],
  body: {
    type: "object",
    properties: {
      phone: { type: "string", description: "手机号" },
      code: { type: "string", description: "短信验证码" },
      account: { type: "string", description: "账户" },
      password: { type: "string", description: "密码" },
    },
  },
};

exports.UnsubscribeSchema = {
  summary: "账户注销",
  tags: ["Common"],
  ...requiredHeaders,
  body: {
    type: "object",
    properties: {
      phone: { type: "string", description: "手机号" },
      code: { type: "string", description: "短信验证码" },
      confirm: { type: "boolean", description: "是否确认注销", default: false },
    },
  },
};

exports.LoginOutSchema = {
  summary: "账户退出",
  tags: ["Common"],
  ...requiredHeaders,
};

exports.RetrievePasswordSchema = {
  summary: "找回密码",
  tags: ["Common"],
  body: {
    type: "object",
    properties: {
      phone: { type: "string", description: "手机号" },
      code: { type: "string", description: "短信验证码" },
      newPassword: { type: "string", description: "新密码" },
      confirm: { type: "boolean", description: "是否确认新密码", default: false },
    },
  },
};

exports.SMScodeSchema = {
  summary: "获取短信验证码",
  tags: ["Common"],
  body: {
    type: "object",
    properties: {
      phone: { type: "string", description: "手机号" },
    },
  },
};

exports.BundledSchema = {
  summary: "绑定账户密码",
  tags: ["Common"],
  ...requiredHeaders,
  body: {
    type: "object",
    properties: {
      phone: { type: "string", description: "手机号" },
      code: { type: "string", description: "短信验证码" },
      account: { type: "string", description: "账户" },
      password: { type: "string", description: "密码" },
    },
  },
};

exports.UserInfoSchema = {
  summary: "获取用户信息",
  tags: ["Common"],
  ...requiredHeaders,
};

exports.DELETERoleInfoSchema = {
  summary: "删除角色",
  tags: ["Common"],
  ...requiredHeaders,
  params: {
    type: "object",
    properties: {
      roleId: { type: "string", description: "角色id" },
    },
  },
};

exports.POSTRoleInfoSchema = {
  summary: "创建角色",
  tags: ["Common"],
  ...requiredHeaders,
  body: {
    type: "object",
    properties: {
      name: { type: "string", description: "角色名称" },
      description: { type: "string", description: "角色描述" },
      tag: { type: "string", description: "角色标签" },
      level: { type: "integer", description: "角色等级" },
      permissions: {
        type: "array",
        description: "角色权限列表",
        items: {
          type: "object",
          properties: {
            id: { type: "string", description: "权限id" },
            url: { type: "string", description: "权限url" },
            label: { type: "string", description: "权限名称" },
            method: { type: "string", description: "权限方法" },
          },
        },
      },
    },
  },
};

exports.PUTRoleInfoSchema = {
  summary: "更新角色",
  tags: ["Common"],
  ...requiredHeaders,
  params: {
    type: "object",
    properties: {
      roleId: { type: "string", description: "角色id" },
    },
  },
  body: {
    type: "object",
    properties: {
      name: { type: "string", description: "角色名称" },
      description: { type: "string", description: "角色描述" },
      tag: { type: "string", description: "角色标签" },
      level: { type: "integer", description: "角色等级" },
      permissions: {
        type: "array",
        description: "角色权限列表",
        items: {
          type: "object",
          properties: {
            url: { type: "string", description: "权限url" },
            name: { type: "string", description: "权限名称" },
            method: { type: "string", description: "权限方法" },
          },
        },
      },
    },
  },
};

exports.GETRoleInfoSchema = {
  summary: "获取角色列表",
  tags: ["Common"],
  ...requiredHeaders,
  querystring: {
    type: "object",
    properties: {
      page: { type: "integer", description: "页码" },
      pageSize: { type: "integer", description: "每页条目数" },
      name: {
        type: "string",
        description: "角色名称",
      },
    },
  },
};

exports.AllapiSchema = {
  summary: "获取api列表",
  tags: ["Common"],
  ...requiredHeaders,
  querystring: {
    type: "object",
    properties: {
      page: { type: "integer", description: "页码" },
      pageSize: { type: "integer", description: "每页条目数" },
      name: {
        type: "string",
        description: "api名称",
      },
      path: {
        type: "string",
        description: "api路径",
      },
      tags: {
        type: "string",
        description: "api标签",
      },
    },
  },
};

exports.BindroleSchema = {
  summary: "绑定角色",
  tags: ["Common"],
  ...requiredHeaders,
  body: {
    type: "object",
    properties: {
      userId: { type: "string", description: "用户id" },
      roleId: { type: "string", description: "角色id" },
    },
  },
};

exports.GETQrcodeInfoSchema = {
  summary: "获取二维码列表",
  tags: ["Common"],
};

exports.POSTQrcodeInfoSchema = {
  summary: "生成二维码",
  tags: ["Common"],
  body: {
    // type: "object",
    properties: {
      name: { type: "string", description: "昵称" },
      height: { type: "string", description: "身高" },
      weight: { type: "string", description: "体重" },
      gender: {
        type: "integer",
        enum: [1, 0],
        description: "性别枚举值。合法值包括：\n1. 1 - 男 \n2. 0 - 女",
      },
      telephone: { type: "string", description: "手机号" },
      photoUrls: { type: "string", format: "binary", description: "个人照" },
    },
  },
};

exports.PUTQrcodeInfoSchema = {
  summary: "更新二维码",
  tags: ["Common"],
};

exports.DELETEQrcodeInfoSchema = {
  summary: "删除二维码",
  tags: ["Common"],
};

exports.GETIDQrcodeInfoSchema = {
  summary: "获取二维码信息",
  tags: ["Common"],
};
